<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
	<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript">
        function on_del_dept(deptno){
          var dept = $('#dept_table').treegrid('find',deptno);
          if (dept == null)
          {
          	return;
          }

          if (confirm('确定删除机构['+dept.text+']吗?'))
          {
            $.ajax({type:"POST",url:'delDept.action',data:{deptno:dept.id},
            error:function(){
				alert("系统错误，服务器可能已关闭！");
			},
            success:function (result){
              if (result.result.code=='0')
              {
                $('#dept_table').treegrid('remove', deptno);
              }
              $.messager.alert('删除机构', result.result.message, 'info');
              
            }});
          }
        }
        
        function on_node_delete(value,row,index){
          return '<a class="delclass" href="#" onclick="on_del_dept(\''+row.id+'\')">删除</a>';
        }

    	$(document).ready(function(){
  	      	var fields = [ 	      	            
	        	{field:'id',title:'机构号',width:120,align:'center'},
	        	{field:'deptname',title:'机构名称',width:260,align:'center'},
	        	{field:'depttypename',title:'机构类型',width:80,align:'center'},
	        	{field:'deptaddr',title:'机构地址',width:260,align:'center'},
	        	{field:'telephone',title:'联系电话',width:120,align:'center'},
	        	{field:'updeptno',title:'上级机构号',width:120,align:'center'},
	        	{field:'action',title:'删除',width:120,align:'center',formatter:on_node_delete}
	      	];
    	
    		$('#dept_table').treegrid({url:'queryDeptTree.action',
    			onLoadError: function(){alert('系统错误，服务器可能已关闭！')},
    			treeField:'id',idField:'id',columns:[fields],striped:'true'});
     		$('#del_dept_panel').panel();
    	});
    </script>
	</head>
	<body>
	
    <div id="del_dept_panel" collapsible="false" fit="true" title="删除机构" 
    	resizable="false" collapsible="false" minimizable="false" 
    	maximizable="false" closable="true" icon="icon-save" class="jquery_panel">
    	<table id="dept_table" title="机构信息表" singleSelect="true" fit="true" fitColumns="true"></table>
    </div>
    
    </body>
</html>